chipschallengefandomcom-20200213-history
C2M
Overview A '''C2M '''file (having the extension .c2m) is the file format which Chip's Challenge 2 individual levels are commonly stored in. The file is a binary file consisting of several sections one after the other, terminated by the END section. Each section begins with a section header, which is followed by the section's data. All data in the file is little-endian. Section header format Section types OPTN section The size of the section can differ between file versions (and even between files with the same file version). Data beyond the size of the section is not read. (E.g. if the section size is 3, only the time and the view are stored.) Section packing The PACK and PRPL sections contain compressed versions of the MAP and REPL sections respectively. The compression scheme is as follows: A Data Block: When encountered during decompression, the data block's N bytes of data are added to the list.. A Back-Reference Block: When encountered during decompression, COUNT bytes are copied from position (CURRENT - OFFSET) in the list to position CURRENT in the list. (Where CURRENT is the current position in the list, while COUNT and OFFSET are defined below) Note that COUNT can be larger than OFFSET, allowing arbitrary pattern repetition to be efficiently encoded. MAP / PACK section This section contains the map data. If this is a PACK section, it must be unpacked using the above compression scheme first. The contents of this section is as follows: Tile specification: The tile specification consists of 1 or more bytes. The first byte is always the tile value, decoded as follows: Direction Byte The direction byte comes after enemy tiles and some others: Panel/Canopy Bitmask Any number of these bits can be combined: Directional Arrows Bitmask Any number of these bits can be combined: Tile Modifiers The modifier "tiles" (0x76, 0x77, 0x78) affect the tile specification that they carry in their additional data. The meaning of the modifier value depends on the type of tile they affect. Wire Modifier This is an 8-bit modifier that affects floors, metal walls, on/off switches, transformers, and blue/red fans (possibly more?). It adds wires to the tile it affects. Any number of these bits can be combined: ASCII Modifier This is an 8-bit modifier that affects "sunken" floors by adding a symbol (usually an ASCII symbol) to them: Clone Machine Arrow Modifier This is an 8-bit modifier that affects clone machines by specifying their direction. The values can be combined and will show up on the clone machine appropriately, but the game will only clone in one direction: Custom Floor/Wall Modifier This is an 8-bit modifier that affects custom walls or floors by replaces their style: Logic Modifier This is an 8-bit modifier that affects an inverter gate by replacing it with another gate: Track Modifier This is an 8- or 16-bit modifier that affects the train tracks base tile. The low-order byte specifies which tracks exist; any number of bits can be combined: The high order byte is optional and specifies which track is the active one. If omitted, the North East track is the active one. For tiles with a track switch, the active track is the only one that can be used (the other are shown red). REPL / PRPL section This section contains the replay data. If this is a PRPL section, it must be unpacked first (see Section Packing). The contents of this section are as follows: Input Change Specifies a change in input: Input Bitmask Specifies which keys are pressed, any number of bits can be combined: Category:Terminology